@extends('admin.main')
@section('head')
    @include('UEditor::head')
    <style>

        .choose-div :hover{
            background: #adda8f;
            color: #fff
        }

        .upload-button {
            position: relative;
            display: inline-block;
            padding: 4px 12px;
            overflow: hidden;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
            color: #fff;
            background-color: #27ae60;
            text-align: center;
            width: 100px;
        }

        .upload-button input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }

        .upload-img-box .upload-pre-item {
            float: left;
            padding: 0px;
            margin: 1px 10px 1px 1px;
            width: 150px;
            max-height: 180px;
            overflow: hidden;
            text-align: center;
            cursor: pointer;
            border: 1px solid #ccc;
            transition: all .3s linear;
        }

        .upload-pre-item img {
            border-bottom: 1px solid #ccc;
        }

        .upload-pre-item div {
            background-color: lightgrey;
        }

        .xdsoft_custom .xdsoft_range2dslider_runner {
            border-radius: 1px;
            margin: 0px 0px -4px -8px !important;
            background: rgba(0, 0, 127, 0.5);
            border: 1px outset #ddd;
        }

        .xdsoft_custom .xdsoft_range2dslider_box {
            min-height: 8px;
            background: rgba(127, 127, 127, 0.5);
            border-radius: 1px;
            border-style: solid;
        }

        .xdsoft_custom .xdsoft_slider_label {
            background: red;
            color: #fff;
            bottom: 22px !important;
        }

        .xdsoft_custom .xdsoft_slider_label.xdsoft_slider_label_top:after {
            border-top-color: red;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/static/range/jquery.range2dslider.css">
    <script src="/static/citys/city.data-3.js" type="text/javascript"></script>
    <script src="/static/citys/jquery.citys.js" type="text/javascript"></script>
    <script src="/static/range/jquery.range2dslider.js" type="text/javascript"></script>
    <script charset="utf-8"
            src="https://map.qq.com/api/js?v=2.exp&key=RHHBZ-K26W6-CPISS-ENGXG-HVCRS-QJFQT&libraries=drawing,geometry,autocomplete,convertor"></script>
    <script type="text/javascript"
            src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js"></script>
@endsection
@section('body')
    <div class="main-title">
        <h2>设置店铺信息</h2>
    </div>
    <div class="tab-wrap">
        <div class="tab-content">
            <form action="" method="post" class="form-horizontal">
                <div id="tab1" class="tab-pane in tab1">
                    <div class="controls" id="shop_logo">
                        <label class="item-label">店铺logo<span class="check-tips">（请上传尺寸为80*80的图片，格式为jpg、png、gif，上传图片大小必须在2M以下）</span></label>
                        <div class="upload-button">
                            <span class="uploadify-button-text">上传图片</span>
                            <input type="file" id="uploadLogo" accept="image/png,image/jpeg,image/gif" num="1"
                                   onchange="upload(this,'shop_logo','logo[]')"
                                   count="{{file_exists(public_path('uploads/logos/imgs/'.$info['admin_id'].'/'.$info['id'].'_1.'.$ext)) ? 1 : 0}}"/>
                        </div>
                        <div class="upload-img-box">
                            @if(file_exists(public_path('uploads/logos/imgs/'.$info['admin_id'].'/'.$info['id'].'_1.'.$ext)))
                                <div class="upload-pre-item" id="shop_logo_1">
                                    <img src="/uploads/logos/imgs/{{$info['admin_id']}}/{{$info['id'].'_1'}}.{{$ext}}?{{time()}}"/>
                                    <div class="shop_logo" onclick="delImg('uploadLogo','shop_logo_1')">
                                        删除
                                    </div>
                                    <input type="hidden" name="logo[]" class="logo"
                                           value="/uploads/logos/imgs/{{$info['admin_id']}}/{{$info['id'].'_1'}}.{{$ext}}">
                                </div>
                            @endif
                        </div>
                    </div>
                    <div id="tab1" class="tab-pane in tab1">
                        <div class="controls" id="shop_img">
                            <label class="item-label">店铺图片<span class="check-tips">（请上传尺寸为400*150的图片，格式为jpg、png、gif，上传图片大小必须在2M以下）</span></label>
                            <div class="upload-button">
                                <span class="uploadify-button-text">上传图片</span>
                                <input type="file" id="uploadImage" accept="image/png,image/jpeg,image/gif" num="1"
                                       onchange="upload(this,'shop_img','imgs[]')"
                                       count="{{isset($info) ? $info['pic_num'] : 0}}"/>
                            </div>
                            <div class="upload-img-box">
                                @if(isset($info) && $info['pic_num'])
                                    @for ($i = 1; $i <= $info['pic_num']; $i++)
                                        @if(file_exists(public_path('uploads/shops/imgs/'.$info['admin_id'].'/'.$info['id'].'_'.$i.'.'.$ext)))
                                            <div class="upload-pre-item" id="shop_img_{{$i}}">
                                                <img src="/uploads/shops/imgs/{{$info['admin_id']}}/{{$info['id']}}_{{$i}}.{{$ext}}?{{time()}}"/>
                                                <div class="shop_img_{{$i}}"
                                                     onclick="delImg('uploadImage','shop_img_{{$i}}')">删除
                                                </div>
                                                <input type="hidden" name="imgs[]" class="shop_img_{{$i}}"
                                                       value="/uploads/shops/imgs/{{$info['admin_id']}}/{{$info['id']}}_{{$i}}.{{$ext}}">
                                            </div>
                                        @endif
                                    @endfor
                                @endif
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">微信支付功能<span class="check-tips"></span></label>
                            <div class="controls">
                                <label class="radio"><input type="radio" name="online_pay" value="1"
                                                            @if(isset($info['online_pay']) && $info['online_pay'] == 1) checked @endif>开启</label>
                                <label class="radio"><input type="radio" name="online_pay" value="0"
                                                            @if(!isset($info['online_pay']) ||  $info['online_pay'] == 0) checked @endif >关闭</label>
                            </div>
                        </div>

                        <div class="form-item">
                            <label class="item-label">货到付款功能<span class="check-tips"></span></label>
                            <div class="controls">
                                <label class="radio"><input type="radio" name="offline_pay" value="1"
                                                            @if(isset($info['offline_pay']) && $info['offline_pay'] == 1) checked @endif>开启</label>
                                <label class="radio"><input type="radio" name="offline_pay" value="0"
                                                            @if(!isset($info['offline_pay']) ||  $info['offline_pay'] == 0) checked @endif >关闭</label>
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">接单模式<span class="check-tips"></span></label>
                            <div class="controls">
                                <label class="radio"><input type="radio" name="send_mode" value="0" @if(!isset($info['send_mode']) || $info['send_mode'] == 0) checked  @endif>抢单模式</label>
                                <label class="radio"><input type="radio" name="send_mode" value="1" @if(isset($info['send_mode']) &&  $info['send_mode'] == 1) checked  @endif >打印机模式</label>
                                <label class="radio"><input type="radio" name="send_mode" value="2" @if(isset($info['send_mode']) &&  $info['send_mode'] == 2) checked  @endif >绑定模式</label>
                                <label class="radio"><input type="radio" name="send_mode" value="3" @if(isset($info['send_mode']) &&  $info['send_mode'] == 3) checked  @endif >分配模式</label>
                            </div>
                            <ul style="background-color: gainsboro">
                                <li>抢单模式：由送水工自主接单派送，不需要人工分配</li>
                                <li>打印机模式：所有订单均由打印机接单，水站根据打印单据统一安排送水工派送，配送端不显示待接单</li>
                                <li>绑定模式：将用户绑定到送水工，用户下单后系统自动安排订单给送水工派送</li>
                                <li>分配模式：所有订单均由水站人工分配派送人员，配送端不显示待接单</li>
                            </ul>
                        </div>
                        <div class="form-item">
                            <label class="item-label">购买上下限</label>
                            <div class="controls">
                                <input type="number" class="text" name="buy_min" min="1" max="100" placeholder="购买下限" value="{{isset($info['buy_min']) && $info['buy_min'] > 0 ? $info['buy_min'] : 1}}"/>
                                <input type="number" class="text" name="buy_max" min="1" max="100" placeholder="购买上限" value="{{isset($info['buy_max']) && $info['buy_max'] > 0 ? $info['buy_max'] : 100}}"/>
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">最低提现金额<span class="check-tips">(元)</span></label>
                            <div class="controls">
                                <input type="number" name="withdraw_min" class="text input-large"
                                       value="{{isset($info['withdraw_min']) ? $info['withdraw_min'] : 0}}">
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                营业时间<span class="check-tips">(格式：8：30 —  17：30)</span>
                            </label>
                            <div class="controls">
                                <input type="text" name="work_time" class="text input-large"
                                       value="{{isset($info['work_time']) ? $info['work_time'] : ''}}">
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                联系方式<span class="check-tips">(店铺联系方式，手机号或座机号)</span>
                            </label>
                            <div class="controls">
                                <input type="text" name="contact" class="text input-large"
                                       value="{{isset($info['contact']) ? $info['contact'] : ''}}">
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                催单电话<span class="check-tips">(用户催单联系方式，手机号)</span>
                            </label>
                            <div class="controls">
                                <input type="text" name="cd_contact" class="text input-large"
                                       value="{{isset($info['cd_contact']) ? $info['cd_contact'] : ''}}">
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">催单功能<span class="check-tips"></span></label>
                            <div class="controls">
                                <label class="radio"><input type="radio" name="cui_dan" value="1"
                                                            @if(isset($info['cui_dan']) && $info['cui_dan'] == 1) checked @endif>开启</label>
                                <label class="radio"><input type="radio" name="cui_dan" value="0"
                                                            @if(!isset($info['cui_dan']) ||  $info['cui_dan'] == 0) checked @endif >关闭</label>
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                地址<span class="check-tips">(省市区)</span>
                            </label>
                            <div class="controls">
                                <input type="text" name="area_info" id="area_info" class="text input-large"
                                       value="{{isset($info['area_info']) ? $info['area_info'] : ''}}">
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                店铺地址<span class="check-tips">(店铺地址，可完善)</span>
                            </label>
                            <div class="controls">
                                <input type="text" name="address" id='address' class="text input-large"
                                       value="{{isset($info['address']) ? $info['address'] : ''}}">
                            </div>
                        </div>

                        <div class="form-item">
                            <label class="item-label">
                                配送范围<span class="check-tips"></span>
                            </label>
                            <div class="controls" style="position:relative">
                                <div style="width:80%;height:600px" id="container_map"></div>
                                <div style="position:absolute;top:3rem;left:6rem;right:70rem">

                                    <h2 style="display: inline-block;">设置配送范围</h2>
                                    <h3 style="display: inline-block;">(单位:公里)</h3>
                                    <input id="slider4">

                                </div>
                                <div class="choose-div" style="position: absolute;top: -0.5rem;left: 0;width: 18%;height: 400px;background: #fff;z-index: 99999;overflow: hidden;overflow-y: auto;display: none;">

                                </div>
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                配送范围说明<span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <label class="textarea input-large">
                                    <textarea name="send_area"
                                              placeholder="格式：&#13;&#10;1.XXXXXXX&#13;&#10;2.XXXXXXX">{{$info['send_area']}}</textarea>
                                </label>
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">
                                订水须知<span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <label class="textarea input-large">
                                    <textarea name="notice"
                                              placeholder="格式：&#13;&#10;1.XXXXXXX&#13;&#10;2.XXXXXXX">{{$info['notice']}}</textarea>
                                </label>
                            </div>
                        </div>
                        <div class="form-item">
                            <label class="item-label">水票须知</label>
                            <div class="controls">
                                <script id="container" name="bill_notice"
                                        type="text/plain">{!! isset($info['bill_notice']) ? $info['bill_notice'] : '' !!}</script>
                                <!-- 实例化编辑器 -->
                                <script type="text/javascript">
                                    var ue = UE.getEditor('container');
                                </script>
                            </div>
                        </div>
                    </div>
                    <!-- 高级 -->
                    <div class="form-item">
                        <input type="hidden" name="id" value="{{$info['id']}}">
                        <input type="hidden" name="shop_id" value="{{$shop_id}}">
                        <input type="hidden" name="admin_id" value="{{$admin_id}}">
                        <input type="hidden" name="shop_position" id="shop_position" value="{{$info['shop_position']}}">
                        <input type="hidden" name="send_area_radius" id="send_area_radius" value="{{$info['send_area_radius']}}">
                        <input type="hidden" name="province" id="province_id" value="{{$info['province_id']}}">
                        <input type="hidden" name="city" id="city_id" value="{{$info['city_id']}}">
                        <input type="hidden" name="area" id="area_id" value="{{$info['area_id']}}">
                        <button type="submit" id="submit" class="btn submit-btn ajax-post"
                                target-form="form-horizontal">确 定
                        </button>
                        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript">

        function delImg(upInputId, fileId) {
            var _this = $("#" + upInputId);
            var count = parseInt(_this.attr('count'));
            _this.attr('count', count - 1);
            $("#" + fileId).remove();
        }
        function upload(obj, imgId, name) {
            var _self = obj;
            var _this = $(obj);
            var fileReader = new FileReader();
            fileReader.onload = function (e) {
                if (fileReader.readyState == FileReader.DONE) {
                    var file = _self.files[0];
                    var type = file.type;
                    var size = parseInt(file.size);
                    var allowSize = parseInt(2097152); //限制上传图片大小1M以下,2*1024*1024
                    if (size > allowSize) {
                        layer.msg('上传图片大小必须在2M以下');
                        return false;
                    }
                    var accept = _this.attr('accept');//上传图片数量
                    var param_num = _this.attr('num');//上传图片数量
                    var param_count = _this.attr('count');//已上传图片数量
                    var acceptArr = accept.split(",");
                    if ($.inArray(type, acceptArr) < 0) {
                        layer.msg('请上传' + accept + '等格式的文件');
                        return false;
                    }
                    if (param_num == null || param_num == undefined) {
                        _this.attr('num', 1);
                    }
                    if (param_count == null || param_count == undefined) {
                        _this.attr('count', 0);
                    }
                    var num = parseInt(_this.attr('num'));
                    var count = parseInt(_this.attr('count'));
                    if (count < num) {
                        count = count + 1;
                        var upFileId = _this.attr('id');
                        var fileId = imgId + '_' + count;
                        var func = 'delImg("' + upFileId + '","' + fileId + '")';
                        $("#" + imgId).find('.upload-img-box').append(
                            '<div class="upload-pre-item" id="' + fileId + '"><img src="' + this.result + '"/><div class="' + fileId + '" onclick=' + func + '>删除</div><input type="hidden" name="' + name + '" class="' + fileId + '"  value="' + this.result + '"></div>'
                        );
                        _this.attr('count', count);
                    } else {
                        layer.msg('最多上传' + num + '张');
                        return false;
                    }
                    _self.value = ''; //清空上传成功后的value值
                }
            };
            //一次加载多个文件
            var i = 0, src = _self.files;
            fileReader.readAsDataURL(src[i]);
            fileReader.onloadend = function () {
                i++;
                if (i < src.length) fileReader.readAsDataURL(src[i]);
            }
        }


        var geocoder, map,mubiao, circle ,marker ,info ,lat ,lng ,address ,name,center ,nearPost ,shop_center , range_height ,argument_range,search_nearPost= null;

        //已经设置的配送范围
        argument_range = "{{isset($info) ? $info['send_area_radius'] : 0}}";
        if(argument_range == null){
            argument_range = 0;
        }

        address = '{{isset($info['address']) ? $info['address'] : ''}}';

        var region ='';
        var area_info ='{{isset($info['area_info']) ? $info['area_info'] : ''}}';
        if(area_info != undefined && area_info != null && area_info != ''){
            region = area_info.split(' ')[1];
        }
        addressDetail = area_info + address;
        var latLng = '{{isset($info['shop_position']) ? $info['shop_position'] : 0}}';   //数据库获取的经纬度
        if(latLng != undefined && latLng != null && latLng != ''){
            lat = latLng.split(',')[0];
            lng = latLng.split(',')[1];
            //调用初始化函数地图
            init();
        }else if(addressDetail == undefined || addressDetail == null || addressDetail == ''){
            //获取用户当前地址
            var geolocation = new qq.maps.Geolocation("RHHBZ-K26W6-CPISS-ENGXG-HVCRS-QJFQT", "qds");
            var options = {timeout: 8000};
            geolocation.getLocation(showPosition, showErr, options)
            function showPosition(position) {
                province = position.province;
                city = position.city;
                if(city != undefined && city != null && city != ''){
                    region = city;
                }
                area = position.district == undefined || position.district == null || position.district ==  ''?'':position.district;
                lat = position.lat;
                lng = position.lng;
                getAddressCode(province,city,area);
                init();
            };
            //定位失败直接调地图
            function showErr() {
                lat='30.462959';
                lng = '114.419449';
                init();
            };
        }else{
            //地址和经纬度之间进行转换服务
            geocoder = new qq.maps.Geocoder({
                //设置服务请求成功的回调函数
                complete: function(result) {
                    lat = result.detail.location.lat;
                    lng = result.detail.location.lng;
                    latLng = lat+','+lng;
                    $('#shop_position').val(latLng);

                    //调用初始化函数地图
                    init();

                },
                //若服务请求失败，则运行以下函数
                error: function() {
                    layer.msg('店铺地址定位出错，请在地图上自行选择');
                }
            });
            //如果没有经纬度 那么 按照店铺地址获取经纬度
            geocoder.getLocation(addressDetail);

        }


        //直接加载地图
        //初始化地图函数  自定义函数名init
        function init() {
            center = new qq.maps.LatLng(lat, lng);
            //定义map变量 调用 qq.maps.Map() 构造函数   获取地图显示容器
            map = new qq.maps.Map(document.getElementById("container_map"), {
                center: center,      // 地图的中心地理坐标。
                zoom:13                                                 // 地图的中心地理坐标。
            });

            marker = new qq.maps.Marker({
                //设置Marker的位置坐标
                position: center,
                //设置显示Marker的地图
                map: map
            });
            //设置Marker是否可以被拖拽，为true时可拖拽，false时不可拖拽，默认属性为false
            marker.setDraggable(false);
            //添加信息窗口
            info = new qq.maps.InfoWindow({
                map: map
            });
            //获取标记的可拖动属性
            info.open();
            info.setContent('<p style="color:  #25bdef">店铺地址</p>');
            info.setPosition(marker.getPosition());

            $('#slider4').range2DSlider({
                grid:false,
                height:0,
                className:'xdsoft_custom',
                showLegend:[1,0],
                axis:[[0,50]],
                tooltip:['top'],
                alwShowTooltip:[true],
                allowAxisMove:['x'],
                printLabel:function( val ){
                    console.log(val)
                    val[0] = Number(val[0])
                    circle_map(val[0].toFixed(0)*1000);
                    $('#send_area_radius').val(val[0].toFixed(0));
                    return val[0].toFixed(0);

                }
            }).range2DSlider('value',[[argument_range,0]]);

            geocoder = new qq.maps.Geocoder({
                complete : function(result){
                    marker.setMap(null);
                    info.setMap(null);
                    // debugger
                    lat = result.detail.location.lat;
                    lng = result.detail.location.lng;

                    $('#shop_position').val(lat+','+lng);
                    make_map(lat,lng);

                }
            });

            //绑定单击事件添加参数
            qq.maps.event.addListener(map, 'click', function(event) {
                marker.setMap(null);
                info.setMap(null);
                console.log(event)
                //根据获取的经纬度 得到具体地址
                var latLng = new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng());
                geocoder.getAddress(latLng);
                if(geocoder!=undefined && geocoder!=null && geocoder != ''){
                    //设置服务请求成功的回调函数
                    geocoder.setComplete(function(result) {
                        nearPost = result.detail;
                        province = nearPost.addressComponents.province;
                        city = nearPost.addressComponents.city;
                        area = (nearPost.addressComponents.district == undefined || nearPost.addressComponents.district == null || nearPost.addressComponents.district == '')?'':nearPost.addressComponents.district;
                        getAddressCode(province,city,area);
                        search_nearPost = nearPost.nearPois;
                        make_address_list(search_nearPost,2);
                        $('.choose-div').show();
                    });
                }
            });
        }

        function make_address_list(list,type) {
            if(list != undefined && list != null && list != ''){
                console.log(list)
                var tableContent = "";
                for(var i=0;i<list.length;i++){
                    var obj = list[i];
                    var detail = obj.name;
                    if(type == 1){
                        detail = obj.title;
                        //获取省市区
                        province = obj.province || '';
                        city = obj.city || '';
                        area = obj.district || '';
                        getAddressCode(province,city,area);

                    }

                    tableContent += '<div class="bac" onclick="changedAddress('+i+')"  style="padding:1rem;border-bottom:2px solid #ece9e9"><p>'+obj.address+'</p><p style="font-size:0.6rem">'+ detail +'</p></div>';
                }
                $('.choose-div').html(tableContent);
            }
        }

        function changedAddress(i){

            var obj = search_nearPost[i];
            province = obj.province;
            city = obj.city;
            area = obj.district || '';
            console.log(obj);
            var address = obj.name?obj.name:obj.title;
            $('#address').val(address);
            var latLng = ''
            if(obj.latLng == undefined || obj.latLng == null || obj.latLng == ''){
                latLng = obj.location.lat +','+obj.location.lng;
                lat = obj.location.lat;
                lng = obj.location.lng;
            }else{
                latLng = obj.latLng.lat +','+obj.latLng.lng;
                lat = obj.latLng.lat;
                lng = obj.latLng.lng;
            }
            marker.setMap(null);
            info.setMap(null);
            make_map(lat,lng);
            $('#shop_position').val(latLng);

            $('.choose-div').hide();
            getAddressCode(province,city,area)

        }

        //根据省市区 获取对应编码
        function getAddressCode(province,city,area) {

            area_info = province + ' '+ city
            if(area != undefined && area != null && area != ''){
                area_info += ' '+area;
            }
            $('#area_info').val(area_info);
            //将省市区放到对应区域
            var p_id='';
            var c_id='';
            var a_id='';
            if(cityData3 == undefined || cityData3 == null || cityData3 == '' || cityData3.length <=0){
                return;
            }
            for(var i=0;i<cityData3.length;i++){
                var data = cityData3[i];
                if(data.text == province){
                    p_id = data.value
                    $('#province_id').val(data.value);
                    var children = data.children;
                    if(children!=undefined && children != null && children !='' && children.length > 0){
                        for(var j = 0;j<children.length;j++){
                            if(children[j].text == city){
                                c_id = children[j].value;
                                $('#city_id').val(children[j].value);
                                children = children[j].children;
                                if(children!=undefined && children != null && children !='' && children.length > 0){
                                    for(var m =0;m<children.length;m++){
                                        if(children[m].text == area){
                                            a_id = children[m].value;
                                            $('#area_id').val(children[m].value);
                                            getAreaInfo(a_id);

                                            break;
                                        }else if(m >= children.length -1){
                                            $('#area_id').val(c_id);
                                            getAreaInfo(c_id);

                                        }
                                    }
                                }else{
                                    $('#area_id').val(c_id);
                                    getAreaInfo(c_id);
                                }
                                break;
                            } else if(j >= children.length-1) {
                                $('#city_id').val(children[j].value);
                                $('#area_id').val(c_id);
                                getAreaInfo(p_id);
                            }
                        }
                    }
                    break;
                }
            }
        }



        function make_map(lat, lng) {
            marker.setMap(null);
            info.setMap(null);
            center = new qq.maps.LatLng(lat, lng);
            map.setCenter(center);
            marker = new qq.maps.Marker({
                map: map,
                position: center
            });
            info = new qq.maps.InfoWindow({
                map: map
            });
            //获取标记的可拖动属性
            info.open();
            info.setContent('<p style="color:  #25bdef">店铺地址</p>');
            info.setPosition(marker.getPosition());

            $('#slider4').range2DSlider({
                grid: false,
                height: 0,
                className: 'xdsoft_custom',
                showLegend: [1, 0],
                axis: [[0, 50]],
                tooltip: ['top'],
                alwShowTooltip: [true],
                allowAxisMove: ['x'],
                printLabel: function (val) {
                    console.log(val)
                    val[0] = Number(val[0]);
                    circle_map(val[0].toFixed(0) * 1000);
                    $('#send_area_radius').val(val[0].toFixed(0));
                    return val[0].toFixed(0);

                }
            }).range2DSlider('value', [[argument_range, 0]]);
        }

        function circle_map(argument) {
            marker.setMap(null);
            info.setMap(null);
            // body...
            if (circle != undefined && circle != null && circle != '') {
                circle.setMap(null);
            }

            center = new qq.maps.LatLng(lat, lng);
            map.setCenter(center);
            circle = new qq.maps.Circle({
                map: map,
                center: center,
                radius: argument,
                strokeWeight: 1
            });
            marker = new qq.maps.Marker({
                map: map,
                position: center
            });
            info = new qq.maps.InfoWindow({
                map: map
            });
            //获取标记的可拖动属性
            info.open();
            info.setContent('<p style="color:  #25bdef">店铺地址</p>');
            info.setPosition(marker.getPosition());
        }

        function codeLatLng(lat, lng) {
            //获取输入框的经纬度
            var latLng = new qq.maps.LatLng(lat, lng);
            //对指定经纬度进行解析
            geocoder.getAddress(latLng);
            //设置服务请求成功的回调函数
            geocoder.setComplete(function (result) {
                console.log(result)
                nearPost = result.detail;
            });
            //若服务请求失败，则运行以下函数
            geocoder.setError(function () {
                return null;
            });
        }

        function getAreaInfo(a_id){
            //将此省市区放到select中
            $('#area').citys({
                code:a_id,
                required: false,
                nodata: 'disabled',
                onChange: function (data) {
                    $('#area_info').val(data['province'] + ' ' + data['city'] + ' ' + data['area']);
                }
            });
        }

        $('#address').bind("input propertychange", function (event) {
            var infos = $('#address').val();
            if (infos != undefined && infos != null && infos != '') {

                var url = 'https://apis.map.qq.com/ws/place/v1/suggestion/?region=' + region + '&keyword=' + infos + '&output=jsonp&key=RHHBZ-K26W6-CPISS-ENGXG-HVCRS-QJFQT';
                url = encodeURI(url);
                $.ajax({
                    type: "get",
                    url: url,
                    dataType: "JSONP",
                    jsonp: 'callback',
                    success: function (res) {
                        search_nearPost = res.data;
                        console.log(search_nearPost);

                        make_address_list(search_nearPost, 1);
                        $('.choose-div').show();

                    },
                    error: function (res, reson) {
                        mui.toast('请求失败');
                    }
                });

            }
        })

    </script>
@endsection
